/******************************************************************************
 * Copyright (C) 2009 Sanatec					                              *
 * This program is free software; you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program is distributed in the hope   *
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.           *
 * See the GNU General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 *****************************************************************************/
package org.compiere.apps.form;

import org.compiere.model.MAccount;
import org.compiere.model.MAcctSchema;
import org.compiere.model.MCharge;
import org.compiere.util.CLogger;
import org.compiere.util.Env;

/**
 *  Create Charge from Accounts
 *
 *  @author Duman Zhunissov
 *  @version $Id: Navigator.java, v 1.0 2013/09/30 
 */
public class Navigator
{
	/**	Window No			*/
	public int         m_WindowNo = 0;
//	/**	FormFrame			*/
//	private FormFrame 	m_frame;

	/** Account Element     */
	public int         m_C_Element_ID = 0;
	/** AccountSchema       */
	/** Default Charge Tax Category */
	private MAcctSchema  m_acctSchema = null;
	/**	Logger			*/
	public static CLogger log = CLogger.getCLogger(Charge.class);

	
    /**
     * Gets the account for the specified charge and element value.
     * The account is created if it doesn't already exist.
     * @param elementValueId    identifier for the element value
     * @param charge            charge
     * @return the account
     */
    private MAccount getAccount(int elementValueId, MCharge charge)
    {
        MAccount defaultAccount = MAccount.getDefault(m_acctSchema, true); //  optional null
        MAccount account = MAccount.get(Env.getCtx(),
            charge.getAD_Client_ID(),
            charge.getAD_Org_ID(),
            m_acctSchema.getC_AcctSchema_ID(),
            elementValueId,
            defaultAccount.getC_SubAcct_ID(),
            defaultAccount.getM_Product_ID(),
            defaultAccount.getC_BPartner_ID(),
            defaultAccount.getAD_OrgTrx_ID(),
            defaultAccount.getC_LocFrom_ID(),
            defaultAccount.getC_LocTo_ID(),
            defaultAccount.getC_SalesRegion_ID(),
            defaultAccount.getC_Project_ID(),
            defaultAccount.getC_Campaign_ID(),
            defaultAccount.getC_Activity_ID(),
            defaultAccount.getUser1_ID(),
            defaultAccount.getUser2_ID(),
            defaultAccount.getUserElement1_ID(),
            defaultAccount.getUserElement2_ID());

        return account;
    }

}   //  Navigator
